/*
 * Copyright (c) 2025, 廖树财, <study_2030@163.com>
 *
 * PHS2.0-YCYW is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2     
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#pragma once
#include "ota.h"
#include "microApp.h"
#include "cjson/cJSON.h"
#include <time.h>

/// @brief 进程传参
typedef struct ota_update_progress
{
    IOTA_OTA_UPDATE_PARAM *param;
    ST_IOTA_LOG_RES *progressDecs;
} ota_update_progress;

int update_check(IOTA_OTA_UPDATE_PARAM param);

bool send_progress(int code, int progress, ST_IOTA_LOG_RES *progressDecs);

bool send_package_progress(int code, int progress, char *appId,char *appName , char *appVersion ,ST_IOTA_LOG_RES *progressDecs);

bool send_childDevice_progress(int code, int progress,char *subDeviceId, ST_IOTA_LOG_RES *progressDecs);

int nvr_package_update(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int nvr_firmware_update(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int nvr_firmware_update_songjian(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int nvr_app_update(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int nvr_algorithm_update(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int nvr_config_update(IOTA_OTA_UPDATE_PARAM param, char *filename, ST_IOTA_LOG_RES *progressDecs);

int sub_update(IOTA_OTA_UPDATE_PARAM param, ST_IOTA_LOG_RES *progressDecs);

